package com.itcast.controller;

import com.itcast.pojo.*;
import com.itcast.service.EmpService;
import com.itcast.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
public class ReportController {
    @Autowired
    private EmpService empService;

    @Autowired
    private StudentService studentService;
    /**
     * 员工职位统计
     * @return
     */
    @GetMapping("/report/empJobData")
    public Result empJobData(){
        log.info("员工职位统计");
        EmpJobData empJobData = empService.empJobData();
        return Result.success(empJobData);
    }

    /**
     * 员工性别统计
     * @return
     */
    @GetMapping("/report/empGenderData")
    public Result empGenderData(){
        log.info("员工性别统计");
        List<EmpGenderData> genderDataList = empService.empGenderData();
        return Result.success(genderDataList);
    }

    /**
     * 统计学员的学历信息
     * @return
     */
    @GetMapping("/report/studentDegreeData")
    public Result studentDegreeData(){
        log.info("统计学员的学历信息");
        List<StudentDegreeData> degreeDataList = studentService.studentDegreeData();
        return Result.success(degreeDataList);
    }

    /**
     * 统计每一个班级的人数
     * @return
     */
    @GetMapping("/report/studentCountData")
    public Result studentCountData(){
        log.info("统计每一个班级的人数");
        StudentCountData countDataList = studentService.studentCountData();
        return Result.success(countDataList);
    }

    /**
     * 日志信息的分页查询
     * @return
     */
    @GetMapping("/log/page")
    public Result logList(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10")Integer pageSize){
        PageBean pageBean = empService.logList(page,pageSize);
        return Result.success(pageBean);
    }
}
